<?php

use yii\db\Schema;
use yii\db\Migration;

class m160426_032339_update_user_adnetwork_slot extends Migration
{
    public function up()
    {
        $sql = <<<FINE
         update {{%user}} set adnetwork_slot = '0' where adnetwork_slot = '1';
         UPDATE {{%condition}} as a, {{%condition}} as b set a.use_whitelist = b.use_whitelist, a.is_limit = b.is_limit WHERE a.solution_id = b.solution_id and a.type_id = 21 and b.type_id = 8;
         UPDATE vam_condition_adspace_adnetwork  set is_whitelist = 2;
         UPDATE vam_condition as c, vam_condition_adspace_adnetwork as aa set aa.`status` = 0 WHERE c.solution_id = aa.solution_id and c.type_id = 21 and c.use_whitelist = 0 and c.is_limit = 0;
FINE;
        $this->execute($sql);
        return true;
    }

    public function down()
    {
        return true;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
